package bairui.international.model.domain.jpa;

import com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue;

/**
 *
 * (地址)TB_Address
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_Address#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_address")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("地址")
@com.lianjing.sh.processing.info.annotation.InfoComment("地址")
public class TB_Address
 extends TBSuper_BaseIDAndTimeAndOrderValue
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 姓名 */
		public String getName();
		/** 电话 */
		public String getPhone();
		/** 地区 */
		public String getArea();
		/** 详细地址 */
		public String getDetailAddress();
		/** 用户 */
		public bairui.international.model.domain.jpa.TB_User getUser();
		/** 县ID */
		public Long getTownId();
		/** 默认标志 */
		public Boolean getDefaultFlag();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_Address properties(MustProperties properties) {
		this.setName(properties.getName());
		this.setPhone(properties.getPhone());
		this.setArea(properties.getArea());
		this.setDetailAddress(properties.getDetailAddress());
		this.setUser(properties.getUser());
		this.setTownId(properties.getTownId());
		this.setDefaultFlag(properties.getDefaultFlag());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_Address(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_Address properties(OptionalSingleProperties properties) {
		return this;
	}
	
	
	
	public TB_Address(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 姓名 */
		public String getName();
		/** 电话 */
		public String getPhone();
		/** 地区 */
		public String getArea();
		/** 详细地址 */
		public String getDetailAddress();
		/** 用户 */
		public bairui.international.model.domain.jpa.TB_User getUser();
		/** 县ID */
		public Long getTownId();
		/** 默认标志 */
		public Boolean getDefaultFlag();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_Address properties(CurrentMustProperties properties) {
		this.setName(properties.getName());
		this.setPhone(properties.getPhone());
		this.setArea(properties.getArea());
		this.setDetailAddress(properties.getDetailAddress());
		this.setUser(properties.getUser());
		this.setTownId(properties.getTownId());
		this.setDefaultFlag(properties.getDefaultFlag());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_Address properties(CurrentOptionalSingleProperties properties) {
		return this;
	}
	
	public TB_Address(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_Address(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean
	) {
		update(bean);
	}
	
	public TB_Address update(com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean){
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_Address.this);
			if(isOverride_getOrderValue){
				TB_Address.this.setOrderValue(orderValue);
			}
	
			String name = getName(TB_Address.this);
			if(isOverride_getName){
				TB_Address.this.setName(name);
			}
	
			String phone = getPhone(TB_Address.this);
			if(isOverride_getPhone){
				TB_Address.this.setPhone(phone);
			}
	
			String area = getArea(TB_Address.this);
			if(isOverride_getArea){
				TB_Address.this.setArea(area);
			}
	
			String detailAddress = getDetailAddress(TB_Address.this);
			if(isOverride_getDetailAddress){
				TB_Address.this.setDetailAddress(detailAddress);
			}
	
			bairui.international.model.domain.jpa.TB_User user = getUser(TB_Address.this);
			if(isOverride_getUser){
				TB_Address.this.setUser(user);
			}
	
			Long townId = getTownId(TB_Address.this);
			if(isOverride_getTownId){
				TB_Address.this.setTownId(townId);
			}
	
			Boolean defaultFlag = getDefaultFlag(TB_Address.this);
			if(isOverride_getDefaultFlag){
				TB_Address.this.setDefaultFlag(defaultFlag);
			}
		}
	
		public TB_Address up(){
			return TB_Address.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_Address it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 姓名 */
		private boolean isOverride_getName = true;
		public String getName(TB_Address it) throws Exception { 
			isOverride_getName = false; 
			return null;
		}
		/** 电话 */
		private boolean isOverride_getPhone = true;
		public String getPhone(TB_Address it) throws Exception { 
			isOverride_getPhone = false; 
			return null;
		}
		/** 地区 */
		private boolean isOverride_getArea = true;
		public String getArea(TB_Address it) throws Exception { 
			isOverride_getArea = false; 
			return null;
		}
		/** 详细地址 */
		private boolean isOverride_getDetailAddress = true;
		public String getDetailAddress(TB_Address it) throws Exception { 
			isOverride_getDetailAddress = false; 
			return null;
		}
		/** 用户 */
		private boolean isOverride_getUser = true;
		public bairui.international.model.domain.jpa.TB_User getUser(TB_Address it) throws Exception { 
			isOverride_getUser = false; 
			return null;
		}
		/** 县ID */
		private boolean isOverride_getTownId = true;
		public Long getTownId(TB_Address it) throws Exception { 
			isOverride_getTownId = false; 
			return null;
		}
		/** 默认标志 */
		private boolean isOverride_getDefaultFlag = true;
		public Boolean getDefaultFlag(TB_Address it) throws Exception { 
			isOverride_getDefaultFlag = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_Address() {
	}
	
	public TB_Address(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_Address(
		@lombok.NonNull TB_Address bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setName(bean.getName());
		this.setPhone(bean.getPhone());
		this.setArea(bean.getArea());
		this.setDetailAddress(bean.getDetailAddress());
		this.setUser(bean.getUser());
		this.setTownId(bean.getTownId());
		this.setDefaultFlag(bean.getDefaultFlag());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("姓名")
	@com.lianjing.sh.processing.info.annotation.InfoComment("姓名")
	@javax.persistence.Column(name="name", nullable=false, length=30)
	private String name;

	@com.lianjing.sh.model.common.annotation.Comment("电话")
	@com.lianjing.sh.processing.info.annotation.InfoComment("电话")
	@javax.persistence.Column(name="phone", nullable=false)
	private String phone;

	@com.lianjing.sh.model.common.annotation.Comment("地区")
	@com.lianjing.sh.processing.info.annotation.InfoComment("地区")
	@javax.persistence.Column(name="area", nullable=false, length=255)
	private String area;

	@com.lianjing.sh.model.common.annotation.Comment("详细地址")
	@com.lianjing.sh.processing.info.annotation.InfoComment("详细地址")
	@javax.persistence.Column(name="detailAddress", nullable=false, length=255)
	private String detailAddress;

	@com.lianjing.sh.model.common.annotation.Comment("用户")
	@com.lianjing.sh.processing.info.annotation.InfoComment("用户")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_User user;

	@com.lianjing.sh.model.common.annotation.Comment("县ID")
	@com.lianjing.sh.processing.info.annotation.InfoComment("县ID")
	@javax.persistence.Column(name="townId", nullable=false)
	private Long townId;

	@com.lianjing.sh.model.common.annotation.Comment("默认标志")
	@com.lianjing.sh.processing.info.annotation.InfoComment("默认标志")
	@javax.persistence.Column(name="defaultFlag", nullable=false)
	private Boolean defaultFlag;

	/** get[姓名] */
	public String getName() {
		return this.name;
	}

	/** get[电话] */
	public String getPhone() {
		return this.phone;
	}

	/** get[地区] */
	public String getArea() {
		return this.area;
	}

	/** get[详细地址] */
	public String getDetailAddress() {
		return this.detailAddress;
	}

	/** get[用户] */
	public bairui.international.model.domain.jpa.TB_User getUser() {
		return this.user;
	}

	/** get[县ID] */
	public Long getTownId() {
		return this.townId;
	}

	/** get[默认标志] */
	public Boolean getDefaultFlag() {
		return this.defaultFlag;
	}

	/** set[姓名] */
	public void setName(String name) {
		this.name = name;
	}

	/** set[电话] */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/** set[地区] */
	public void setArea(String area) {
		this.area = area;
	}

	/** set[详细地址] */
	public void setDetailAddress(String detailAddress) {
		this.detailAddress = detailAddress;
	}

	/** set[用户] */
	public void setUser(bairui.international.model.domain.jpa.TB_User user) {
		this.user = user;
	}

	/** set[县ID] */
	public void setTownId(Long townId) {
		this.townId = townId;
	}

	/** set[默认标志] */
	public void setDefaultFlag(Boolean defaultFlag) {
		this.defaultFlag = defaultFlag;
	}

	public void assignUser(bairui.international.model.domain.jpa.TB_User user) {
		if(null != user){
			user.addAddresss(this);
		}
		this.setUser(user);
	}
	

	
	
	

	/** take[用户] */
	public bairui.international.model.domain.jpa.TB_User takeUser(){
		if(null == this.user){
			this.user = new bairui.international.model.domain.jpa.TB_User();
		}
		return this.user;
	}
	
	/** must[用户] */
	public bairui.international.model.domain.jpa.TB_User mustUser() {
		return this.user;
	}
	
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_Address other = (TB_Address) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		String name = this.getName();
		if(null != name){
			return String.valueOf(name);
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		this.setModifyTime(new java.util.Date());
	}



}
